<template>
  <div style="min-width: 1200px;width:100%;">
    <!-- <quick></quick> -->
    <webHeader />

    <nuxt/>
    <div class="common-footer common-fluid">
      <div class="common-container footer-box">
        <p>

          版权所有:<a href="javascript:;">{{ site.icp }}</a> <br> ICP备案号:<a href="/"
                                                                        target="_blank">{{ site.icp }}</a> <a href="javascript:;" style="margin:10px">运营商:{{ site.icp }}</a> <a
          href="/" target="_blank"><img src="http://baota.111zh.cn/Public/Front/xinmeng1/images/icp.png" alt=""
                                        style="margin-right: 5px;vertical-align: middle;width: 1%;">公安网备{{ site.icp2 }}号</a>
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import '@/plugins/element-ui'
import webHeader from '@/components/webHeader5'
import { mapState,mapMutations } from 'vuex'
import fixupMixin from '@/mixins/fixup'
import Quick from '@/components/quick4'
import tabs from '@/constants/navTabs4'
import supplyTabs from '@/constants/supplyNavTabs'
import leftNavs from '@/constants/webLeftNavs'
import supplyLeftNavs from '@/constants/supplyLeftNavs'
import LeftBoard from '@/components/leftBoard'
import vipDialog from '@/components/dialog/updateVip'
import selfUpdate from '@/components/dialog/selfUpdate'
import qplayer from '@/components/themes/qplayer'
import user from '@/common/user'

export default {
  middleware: ['authorization', 'site', 'themes'],
  components: {
    Quick,
    LeftBoard,
    vipDialog,
    selfUpdate,
    qplayer,
    webHeader,
  },
  mixins: [fixupMixin],
  data() {
    return {
      urlArr:['/main4','/category-list4','/goods-list4'],
      tabsClass:[false,false,false,false,false,false],
      fixupPage: 'in',
      activeIndex: '-1',
      isSupply: false,
      isCollapse: false,
      searchTxt: '',
      isWindowHeight: 0,
      linkMenuDataTop: [],
      placeHolderLogo: require('~/assets/images/logo.jpg'),
    }
  },
  created() {
    var url  = this.$route.path;
    this.urlArr.forEach((element,index) => {
      if(url.indexOf(element) != -1){
        this.tabsClass[index] = true;
      }
    });
    if (this.$route.path === '/goods-list') {
      if (this.$route.query.categoryId) {
        this.tabsClass[1] = true
        this.tabsClass[2] = false
      }
    }
    this.getLinkMenuList()
  },
  methods: {
    toLoadAgain () {
      window.location.reload();
    },
    doLogout() {
      user.removeToken(this.$cookies)
      location.href = '/'
    },
    toSearchGoods () {
      if (this.$route.path === '/goods-list') {
        this.setSearchFeach(this.searchTxt)
      } else {
        this.$router.push({
          path: '/goods-list',
          query: {
            keywords: this.searchTxt
          }
        })
      }
    },
    toSearchCatalog () {

      this.$router.push({
        path: '/goods-list4',
        query: {
          keywords: this.searchTxt
        }
      })
    },
    changeClass(){

      this.tabsClass.forEach((item,index)=>{
        this.tabsClass[index] = false;
      })
    },
    checkSupply(nav) {
      if (!nav.isSupply) {
        return true
      }
      // 是true，需要校验用户类型
      const user = this.$store.getters.user
      if (!user.userExtend) {
        return false
      }
      if (user.userExtend.isSupply === 1) {
        return true
      }
      return false
    },
    toUpDatSlider () {
      this.isCollapse = !this.isCollapse
      console.log(this.isCollapse)
    },
    getWindowHeight () {
      let bodyDom = window.screen.availHeight;
      console.log(bodyDom)
      this.isWindowHeight = bodyDom - 63
    },
    async getLinkMenuList() {
      let that = this
      const res = await this.$axios.get('/site/customMenu/listForDomain')
      if (res.code === 1001) {
        if (res.body) {
          that.linkMenuDataTop = res.body
        }
      }
    },
    ...mapMutations([
      'setSearchFeach'
    ])
  },
  computed: {
    ...mapState({
      updateEnable: (state) => state.updateEnable,
      site: (state) => state.site,
      systemStyle: (state) => state.systemStyle,
      user: (state) => state.user,
      page: (state) => state.systemStyle.insideStyle
    }),
    tabList() {
      if (this.isSupply) {
        return supplyTabs
      } else {
        return tabs
      }
    },
    navList() {
      if (this.isSupply) {
        return supplyLeftNavs
      } else {
        return leftNavs
      }
    }
  },
  mounted() {
    for (let i = 0; i < this.navList.length; i++) {
      if (this.navList[i].children) {
        const subList = this.navList[i].children
        for (let j = 0; j < subList.length; j++) {
          if (subList[j].path === location.pathname) {
            this.activeIndex = `${i}-${j}`
            break
          }
        }
      } else {
        if (this.navList[i].path === location.pathname) {
          this.activeIndex = `${i}`
          break
        }
      }

    }
    // } else {
    //   for (let i = 0; i < this.navList.length; i++) {
    //     if (this.navList[i].path === location.pathname) {
    //       this.activeIndex = `${i}`
    //       break
    //     }
    //   }
    // }

    this.getWindowHeight()
  },
  head() {
    return {
      title: this.site.systemName,
      meta: [
        {
          hid: 'description',
          name: 'description',
          content: this.site.remark
        },
        {
          hid: 'keywords',
          name: 'keywords',
          content: this.site.keyWord
        }
      ]
    }
  }
}
</script>

<style lang="scss" scoped>
@import 'element-ui/lib/theme-chalk/index.css';

@import 'assets/style/layer.css';
@import 'assets/style/layui.css';
@import 'assets/style/style2/common.css';
@import 'assets/style/style2/openlogin.css';
@import 'assets/style/style2/style.css';
@import 'assets/style/style2/font_1451715_0505c2bxv7b7.css';
.common-container .logoimg {
  object-fit: fill;
}
</style>
